/* 2017-12-5 16:47:31 | 修改 木遥（微信:  http://marsgis.cn/weixin.html ） */
//模块：
mars3d.widget.bindClass(mars3d.widget.BaseWidget.extend({
    options: {
        resources: [
            './lib/cesiumjs/plugins/heatmap/heatmap.min.js',
            './lib/cesiumjs/plugins/heatmap/HeatmapImageryProvider.js'
        ],
        //弹窗
        view: {
            type: "append",
            url: "view.html"
        },
    },
    //初始化[仅执行1次]
    create: function () {


    },
    //每个窗口创建完成后调用
    winCreateOK: function (opt, result) {
        //此处可以绑定页面dom事件 

        opt._dom.children().attr('src', this.path + 'img/heatmap-tuli.png');
    },
    layer: null,
    //打开激活
    activate: function () {
        var that = this;
        $.getJSON(serverURL_file+"/apidemo/heat.json", function (data) {
            if (data.Code != 0) {
                haoutil.msg(data.Msg);
                return;
            }
            that.addData(data.Data);
        });

    },
    addData: function (arrdata) {

        var heatLayer = new mars3d.HeatmapImageryProvider({
            //min: min, max: max, //可自定义热力值范围，默认为数据中的最大最小值
            data: arrdata,
            heatmapoptions: {//参阅api：https://www.patrick-wied.at/static/heatmapjs/docs.html
                radius: 180,
                minOpacity: 0.2,
                xField: 'X',
                yField: 'Y',
                valueField: 'Count'
            }
        });
        this.layer = this.viewer.imageryLayers.addImageryProvider(heatLayer);

        viewer.camera.flyTo({
            destination: heatLayer.rectangle,
        });
    },
    //关闭释放
    disable: function () {
        if (this.layer) {
            this.viewer.imageryLayers.remove(this.layer);
            this.layer = null;
        }

    },



}));

